// ml:run = $bin < input
#include <iostream>

LL gao(int l, int r) {
    if (vis[l][r]) {
        return dp[l][r];
    }
    if (l == r) {
        vis[l][r] = true;
        dp[l][r] = 0;
        return 0LL;
    }
    if (r == l - 1) {
        vis[l][r] = true;
        return dp[l][r];
    }
    LL now = 0LL;
    for (int i = l; i <= r - 1; i ++) {
        now = max(now, gao(l, i) + gao(i + 1, r));
    }
    LL temp = gao(l + 1, r - 1);
    if (temp == all[r - 1] - all[l]) {
        if (gcd(KV[l].first, KV[r].first) != 1) {
            temp += KV[l].second;
            temp += KV[r].second;
        }
    }
    dp[l][r] = max(now, temp);
    vis[l][r] = true;
    return max(now, temp);
}

int main()
{
    std::ios_base::sync_with_stdio(false);
}

